﻿$(document).ready(function () {
    // Fade out error messages when re-visiting the cell
    $('input', $('#mvc-ajax-page')[0]).live('focus', function () {
        $(this).next('div.formError:first').fadeOut('slow');
    });
    // Allow error messages to be closed by clicking on them
    $('div.formError', $('#mvc-ajax-page')[0]).live('click', function () {
        $(this).fadeOut('slow');
    });
    $('#mvc-ajax-page form', $('#mvc-ajax-page')[0]).live('submit', function () {
        $('div.formError').each(function (index) {
            // Todo: find a way to use position to make the messages appear next to each form field
            var position = $(this).position();
            $(this).attr('top', position.top);
            $(this).attr('left', position.left);
        });
    });
});